package is.progetto1.aritmeticExpression;

import is.progetto1.exception.IllegalContextException;

public abstract class Operator extends Expression {

	protected Expression left = null;
	protected Expression right = null;

	public String getOperator(){
		throw new UnsupportedOperationException();
	}
	
	
	
	@Override
	public int toAssess(Context c) throws IllegalContextException {
		throw new UnsupportedOperationException();
	}



	@Override
	public String toString() {
		throw new UnsupportedOperationException();
	}



	@Override
	public boolean equals(Object o) {
		throw new UnsupportedOperationException();
	}

	@Override
	public final Expression getLeft() {
		return left;
	}

	@Override
	public final Expression getRight() {
		return right;
	}

	@Override
	public final void setLeft(Expression e) {
		this.left = e;
		if(e!=null){
			e.setParent(this);
		}
	}

	@Override
	public final void setRight(Expression e) {
		this.right = e;
		if(e!=null){
			e.setParent(this);
		}
	}

	@Override
	public final Expression toClone() {
		Operator res;
		try {
			res = (Operator) super.clone();
		} catch (CloneNotSupportedException e) {
			return null;
		}
		if (left != null) {
			res.setLeft(left.toClone());
		}
		if (right != null) {
			res.setRight(right.toClone());
		}
		return res;
	}
}
